home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0025_Ctrl-Alt-Del Trapping.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-31  |  3KB  |  105 lines

  1. ==============================================================================
  2.  BBS: ─≡─ The Graphics Connection ─≡─ Speciali
  3.   To: JOE JACOBSON                 Date: 12-20-92 (15:25)
  4. From: GUY MCLOUGHLIN             Number: 1137   [121] Pascal-IL
  5. Subj: CTRL-ALT-DELETE TRAPPING   Status: Public
  6. ------------------------------------------------------------------------------
  7.   ...Unit captured from FIDONET:
  8.  
  9. UNIT CAD;
  10.  
  11. {- Area: PASCAL ---------------------}
  12. {  Date: 10-16-92  22:12             }
  13. {  From: Wilbert van Leijen          }
  14. {    To: John Martzall               }
  15. {  Subj: Ctrl-Alt-Delete             }
  16. {------------------------------------}
  17.  
  18. INTERFACE
  19.  
  20. USES Dos;
  21.  
  22. VAR
  23.   Int9Handler  : POINTER;
  24.  
  25. PROCEDURE InterceptCtrlAltDel;
  26. PROCEDURE RestoreCAD;
  27.  
  28.   IMPLEMENTATION
  29.  
  30. PROCEDURE InterceptCtrlAltDel; Assembler;
  31.  
  32. CONST
  33.   Ctrl         = 4;
  34.   Alt          = 8;
  35.   Del          = $53;
  36.   KbdPort      = $60;                  { Keyboard port }
  37.   KbdCtrlPort  = $61;                  { Keyboard control port }
  38.   PIC          = $20;                  { 8259 Interrupt controller }
  39.   EOI          = $20;                  { End-of-interrupt }
  40.  
  41.   ASM
  42.   { Make sure we can access our global data }
  43.  
  44.   PUSH   AX
  45.   PUSH   DS
  46.   MOV    AX, SEG @Data
  47.   MOV    DS, AX
  48.   STI
  49.  
  50.   { Read keyboard port and mask out the 'break bit'.
  51.           Check whether the <Del> key was pressed. }
  52.  
  53.   IN     AL, KbdPort
  54.   AND    AL, 01111111b
  55.   CMP    AL, Del
  56.   JNE    @2
  57.  
  58.   { <Del> key was pressed, now check whether <Ctrl> and <Alt>
  59.           are held down }
  60.  
  61.   @1 :     MOV    AH, 2               { BIOS Get keyboard flags service }
  62.   INT    16h
  63.   TEST   AL, Ctrl + Alt
  64.   JNZ    @3
  65.  
  66.   { Chain to previous owner of INT 9 }
  67.  
  68.   @2 :     PUSHF
  69.   CALL   [Int9Handler]
  70.   JMP    @4
  71.  
  72.   { Ctrl-Alt-Del combination found: send the break code }
  73.  
  74.   @3 :     IN     AL, KbdCtrlPort
  75.   MOV    AH, AL
  76.   OR     AL, 10000000b
  77.   OUT    KbdCtrlPort, AL
  78.   XCHG   AH, AL
  79.   OUT    KbdCtrlPort, AL
  80.   CLI
  81.  
  82.   { Signal 'End Of Interrupt' to the 8259 interrupt controller chip }
  83.  
  84.   MOV    AL, EOI
  85.   OUT    PIC, AL
  86.   @4 :     POP    DS
  87.   POP    AX
  88.   IRET                       { make sure we return correctly }
  89. END;  { InterceptCtrlAltDel }
  90.  
  91. PROCEDURE RestoreCAD;
  92.  
  93. BEGIN
  94.   SETINTVEC (9, Int9Handler);
  95. END;  { RestoreCAD }
  96.  
  97. BEGIN
  98.   GETINTVEC (9, Int9Handler);
  99.   SETINTVEC (9, @InterceptCtrlAltDel);
  100. END.
  101.                                - Guy
  102. ---
  103.  ■ DeLuxe²/386 1.25 #5060 ■
  104.  ■ QNet3ß ■ ILink - Canada Remote Systems - Toronto, Ont (416) 798-4713
  105.